#include "StdAfx.h"
#include "OptionUtils.h"

Size TsOptionUtils::getNumTimeSteps(const Date &valueDate, const Date &maturity)
{
	BigInteger numDays = maturity.serialNumber() - valueDate.serialNumber();
	QL_REQUIRE(numDays >= 0, "Value date " << valueDate << " occurs after maturity " << maturity << ", check date logic.");

	Size timeSteps = 0;

	if(numDays <= 183)
		timeSteps = (Size)numDays;
	else if(numDays <= 730)
		timeSteps = (Size)(numDays/7.0);
	else if(numDays <= 1825)
		timeSteps = (Size)(numDays/14.0);
	else
		timeSteps = (Size)(numDays/30.0);

	return timeSteps;	
}